<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        th,td{
            width: 200px;
            height: 50px;
            border: 1px solid black;
        }
        table{
            text-align: center;
        }
        tbody tr{
            background-image: linear-gradient(to right top,orange,purple);
        }
        tbody tr:hover{
            background-image: linear-gradient(to right bottom,skyblue,green);
        }
    </style>
</head>
<body>
    <table align="center">
        <thead>
            <tr>
                <th>姓名</th>
                <th>科目</th>
                <th>成绩</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                
            </tr>
        </tbody>
    </table>
</body>
</html>
<script>
    var data=[{
        'xm':'魏璎珞',
        'km':'JS',
        'cj':'100',
    },{
        'xm':'弘历',
        'km':'JS',
        'cj':'90',
    },{
        'xm':'傅恒',
        'km':'JS',
        'cj':'99',
    },{
        'xm':'明玉',
        'km':'JS',
        'cj':'89',
    }]

    var tbody=document.querySelector('tbody')
    //for循环遍历数组
    for(i=0;i<data.length;i++){
        //创建
        var tr=document.createElement('tr')
        //赋值
        //字符串模版
        tr.innerHTML=`
                <td>${data[i].xm}</td>
                <td>${data[i].km}</td>
                <td>${data[i].cj}</td>
                <td><a href="#">删除</a></td>
        `;
        //添加
        tbody.appendChild(tr)
    }
</script>